<style lang="scss">
    .tomour_nav{
        padding:40px 20px;
        .tomour_nav_card{
            width:100%;
            height:115px;
            padding:3px 20px;
            border-radius: 5px;
            box-sizing: border-box;
            text-align: center;
            p{
                font-size:48px;
                text-align:left;
            }
            span{
                font-size:20px;
                display: block;
                text-align:left;
            }
            i{
                font-size:74px;
                margin-top:15px;
            }
        }
        .tomour_nav_card1{
            color:#78c06e;
            border:1px solid #78c06e;
        }
        .tomour_nav_card2{
            color:#1996cd;
            border:1px solid #1996cd;
        }
        .tomour_nav_card3{
            color:#d97b24;
            border:1px solid #d97b24;
        }
        .tomour_nav_card4{
            background: #1996cd;
            color: #fff;
            p{
                font-size:24px;
                line-height: 100px;
            }
            i{
                font-size:60px;
                margin-top:20px;
            }
        }
    }
    .domain{
        padding-top:15px;
        height:731px;
        background: #f5f7f9;
        .domain_table{
            width:75%;
            height:100%;
            padding:20px;
            float:left;
            box-sizing: border-box;
            background: #fff;
            .domain_table_search{
                width:380px;
                float:right;
                .ivu-input-group-append{
                    cursor: pointer;
                    padding:0;
                }
            }
        }
        .domain_echats{
            width:25%;
            padding-left:15px;
            box-sizing: border-box;
            float:right;
            .domain_echats_graph{
                background: #fff;
                margin-bottom: 15px;
                position: relative;
                .domain_echats_header{
                    position: relative;
                    .domain_echats_title{
                        height:43px;
                        background: rgba(82, 92, 121, 1);
                        color:#fff;
                        text-align: center;
                        line-height: 43px;
                    }
                    .domain_echats_exchange{
                        position: absolute;
                        top:0;
                        width:100%;
                        height:43px;
                        line-height:43px;
                        color:#fff;
                        span{
                            float: right;
                            margin-right:15px;
                            font-size:16px;
                            cursor:pointer;
                        }
                    }
                }
                
            }
        }
    }
    .scene{
        padding:70px 0;
        // background: red;
        ul{
            width:200px;
            height:80px;
            margin:auto;
            li{
                float: left;
                text-align: center;
                p{
                    padding-top:10px;
                }
                div{
                    width:80px;
                    height:80px;
                    position: relative;
                    img{
                        margin-top:15px;
                    }
                    .scene_icon{
                        position: absolute;
                        bottom: 0;
                        right: 0;
                        font-size: 18px;
                        height: 18px;
                        line-height: 18px;
                    }
                }
            }
            li+li{
                margin-left:40px;
            }
            li:nth-of-type(1){
                color:#50a02d;
                div{
                    border:1px solid #50a02d;
                    .scene_icon{
                        border-top:1px solid #50a02d;
                        border-left: 1px solid #50a02d;
                    }
                }
            }
            li:nth-of-type(2){
                color:#3f81c1;
                div{
                    border:1px solid #3f81c1;
                    .scene_icon{
                        border-top:1px solid #3f81c1;
                        border-left: 1px solid #3f81c1;
                    }
                }
            }
        }
    }
    .slot-footer{
        height:53px;
        background: rgba(242, 242, 242, 1);
        padding:0;
        .ivu-btn{
            padding:6px 30px;
        }
    }
    .vertical-center-modal{
        display: flex;
        align-items: center;
        justify-content: center;
        .slot-foote{
            padding:0;
        }
        .ivu-modal{
            top: 0;
        }
    }
    .upload {
		padding: 10px 10px 30px;
		background: #fff;
		border-radius: 3px;
		min-height:200px;
		.ivu-btn {
			// background: #767cc3;
			padding: 6px 20px;
			color: #fff;
		}
    }
    .tumour-table{
        position: relative;
        min-height: 450px;
         _height: 450px;
        .el-table {
            min-height: 450px;
        }
    }
</style>
<template>
    <div id="cmain">
        <div class="main_inner">
        <!-- 顶部nav 开始-->
            <div class="tomour_nav">
                <Row type="flex" justify="space-between">
                    <Col span="5">
                        <div style="padding:0;" class="tomour_nav_card tomour_nav_card4" @click="newCase">
                            <Row type="flex" justify="space-between">
                                <Col span="10">
                                    <Icon style="margin-top:27px;" type="ios-plus-outline"></Icon>
                                </Col>
                                <Col span="14">
                                    <p style="height:115px;line-height:115px;">新建病例</p>
                                </Col>
                            </Row>
                        </div>
                    </Col>
                    <Col span="5">
                        <div class="tomour_nav_card tomour_nav_card1" @click="dataChange('4','2')">
                            <Row type="flex" justify="space-between">
                                <Col span="12">
                                    <p>{{dataSize.notUploadCount}}</p>
                                    <span>待上传</span>
                                </Col>
                                <Col span="12">
                                    <Icon type="ios-clock"></Icon>
                                </Col>
                            </Row>
                        </div>
                    </Col>
                    <Col span="5">
                        <div class="tomour_nav_card tomour_nav_card2" @click="dataChange('5','2')">
                            <Row type="flex" justify="space-between">
                                <Col span="12">
                                    <p>{{dataSize.pipelineFinishCount}}</p>
                                    <span>已完成</span>
                                </Col>
                                <Col span="12">
                                    <Icon type="ios-checkmark"></Icon>
                                </Col>
                            </Row>
                        </div>
                    </Col>
                    <Col span="5">
                        <div class="tomour_nav_card tomour_nav_card3" @click="dataChange('6','2')">
                            <Row type="flex" justify="space-between">
                                <Col span="12">
                                    <p>{{dataSize.downloadCount}}</p>
                                    <span>报告下载</span>
                                </Col>
                                <Col span="12">
                                    <Icon type="ios-cloud-download"></Icon>
                                </Col>
                            </Row>
                        </div>
                    </Col>
                </Row>
            </div>
            <!-- 顶部nav 结束-->
            <!-- 功能区 开始 -->
            <div class="domain">
                <!-- 表格 开始 -->
                <div class="domain_table">
                    <Row>
                        <Col span="12">
                            <el-radio-group  v-model="radio5" size="medium">
                                <!-- <el-radio-button label="早期筛查"></el-radio-button> -->
                                <el-radio-button label="诊断治疗"></el-radio-button>
                                <!-- <el-radio-button label="术后跟踪"></el-radio-button> -->
                            </el-radio-group>
                        </Col>
                        <Col span="12">
                            <div class="domain_table_search">
                                <Input v-model="searchData">
                                    <Select v-model="searchValue" slot="prepend" style="width: 80px" @on-change="selectChange">
                                        <Option v-for="(item,index) of searchList" :key="index" :value="item.value" :label="item.label">{{item.label}}</Option>
                                    </Select>
                                    <span slot="append" style="padding:10px 13px;" @click="dataChange(searchValue,searchData)"><Icon type="ios-search" ></Icon></span>
                                </Input>
                            </div>
                        </Col>
                        
                    </Row>
                    <Row>
                        <div class="tumour-table" style="width:100%;padding:15px 0;box-sizing:border-box;">
                            <el-table :data="tableData3" border  height="550" v-if="!isWarn" v-loading="loading" element-loading-text="数据加载中，请稍后" :highlight-current-row="true">
                                <el-table-column label="病人编号" prop="dchPatient.patientcode">
                                    <template slot-scope="scope">
                                        <a  @click="clickPatientcode(scope.row)" href='javascript:;' class="bian">
                                        {{ scope.row.dchPatient.patientcode }} 
                                        </a>
                                    </template>
                                </el-table-column>
                                <el-table-column label="姓名" prop="dchPatient.patientname">
                                </el-table-column>
                                <el-table-column label="取样日期">
                                    <template slot-scope="scope">
                                        <div v-for="list in scope.row.dchSampleList" :key="list.id" class="handle" style="height:40px;line-height:40px;">{{list.takendate}}</div>
                                    </template>
                                </el-table-column>
                                <el-table-column label="样本类型" prop="sample" >
                                    <template slot-scope="scope">
                                        <div v-for="list in scope.row.dchSampleList" :key="list.id" class="handle" style="height:40px;line-height:40px;">{{list.sampletype}}</div>
                                    </template>
                                </el-table-column>          
                                <el-table-column label="样本编号">
                                    <template slot-scope="scope">
                                        <div @click="addsample(scope.row)"style="font-size:12px;text-decoration:underline;color:#3c8dbc;cursor:pointer;" v-if="scope.row.dchSampleList.length==0">添加</div>
                                        <div class="bian"v-for="(list,index) in scope.row.dchSampleList" style="cursor:pointer;color:#3c8dbc;height:auto;"  :key="list.id" @click="samcode(index,scope.row)">{{ list.samplecode }}</div>
                                    </template>
                                </el-table-column>
                                <el-table-column label="传输状态">
                                    <template slot-scope="scope">
                                        <div v-for="(list,index) in scope.row.dchSampleList" :key="index" class="handle" >
                                            <span class="status" v-if="(list.fastq_R1!=null && list.fastq_R2!=null) || list.vcf != null" style="color:#3B79BA;font-size:20px;cursor:pointer;" title="上传完成">
                                                <!-- <Tooltip content="上传完成" placement="top"> -->
                                                    <Icon type="android-done"></Icon>
                                                <!-- </Tooltip> -->
                                            </span>
                                            
                                            <span class="status" style="color:#84BF66;font-size:20px;cursor:pointer;" v-else-if="list.fastq_R1==null && list.fastq_R2==null && list.vcf == null" title="等待上传">
                                                <!-- <Tooltip content="等待上传" placement="top"  > -->
                                                    <Icon type="upload"></Icon>
                                                <!-- </Tooltip> -->
                                            </span> 
                                            
                                            <span class="status" v-else style="color:#3B79BA;font-size:20px;opacity:.5;cursor:pointer;" title="正在上传">
                                                <!-- <Tooltip content="正在上传" placement="top">  -->
                                                    <Icon type="upload"></Icon>
                                                <!-- </Tooltip>  -->
                                            </span>
                                        </div>
                                    </template>
                                </el-table-column>
                                <el-table-column label="分析状态">
                                    <template slot-scope="scope">
                                        <div v-for="(list,index) in scope.row.dchSampleList" :key="index" class="handle" >
                                            <span class="status" v-if="list.samplestatus==1" style="color:#A5ACB3;font-size:20px;cursor:pointer;" title="等待分析">
                                                <!-- <Tooltip content="等待分析" placement="top"> -->
                                                    <Icon type="stats-bars"></Icon>
                                                <!-- </Tooltip> -->
                                            </span>
                                            <span class="status" v-else-if="list.samplestatus==2" style="color:#3B79BA;font-size:20px;cursor:pointer" title="正在分析">
                                                <!-- <Tooltip content="正在分析" placement="top"> -->
                                                    <Icon type="stats-bars"></Icon>
                                                <!-- </Tooltip> -->
                                            </span>
                                            <span class="status" v-else-if="list.samplestatus==3" style="color:#3B79BA;font-size:20px;cursor:pointer" title="分析完成">
                                                <!-- <Tooltip content="分析完成" placement="top"> -->
                                                    <Icon type="android-done"></Icon>
                                                <!-- </Tooltip> -->
                                            </span>
                                            <span class="status" v-else-if="list.samplestatus==4" style="color:##d97b24;font-size:20px;cursor:pointer" title="分析失敗">
                                                <!-- <Tooltip content="分析失敗" placement="top"> -->
                                                    <Icon type="android-close"></Icon>
                                                <!-- </Tooltip> -->
                                            </span>
                                        </div>
                                    </template>
                                </el-table-column>
                                <el-table-column label="操作" min-width="120%">
                                    <template slot-scope="scope">
                                        <div v-for="(list,index) in scope.row.dchSampleList" :key="index" class="handle">
                                            <span class="bian" style="border:none;background:none;color:#ccc;padding: 0px 10px;" disabled v-if="list.samplestatus=='0'||list.samplestatus=='5'">运行</span>
                                            <span class="bian" @click="run(index,scope.row)" v-else-if="list.samplestatus=='6'">运行</span>
                                            <span class="bian" @click="delet(index,scope.row)">删除</span>
                                            <span class="bian" @click="edit(index,scope.row)">编辑</span>
                                            </div>
                                        </template>
                                </el-table-column>
                                <el-table-column label="解读">
                                    <template slot-scope="scope">
                                        <div v-for="(list,index) in scope.row.dchSampleList" :key="index" class="handle" style="height:40px;line-height:40px;">
                                            <a v-if="list.samplestatus==3" @click="jumpVishuourl(list.sampleid,scope.row.dchPatient.patientid)">C GDAP</a>
                                             <a href="javascript:;"  disabled v-else>C GDAP</a> 
                                        </div>
                                    </template>
                                </el-table-column>
                                <el-table-column label="报告下载">
                                    <template slot-scope="scope">
                                        <div v-for="(list,index) in scope.row.dchSampleList" :key="index" class="handle" style="height:40px;line-height:40px;">
                                            <el-button disabled size="mini"v-if="!list.jobtype || list.jobtype!='Y'">下载</el-button>
                                            <el-button type="primary" size="mini" v-if="list.jobtype == 'Y'" @click="download(scope.row)">下载</el-button>
                                        </div>
                                    </template>
                                </el-table-column>
                                <div slot="empty"></div>
                            </el-table>
                            <div v-if='emptyShow' class='empty'>
                                <img style="display:block;float:left;" src="/static/icon/add.png" />
                                <span style="display:block;float:left;margin-top:3px;margin-left:10px;">暂无数据，请创建</span>
                            </div>
                            <warn v-if="isWarn" @callback="load"></warn>
                            <div v-if="!isWarn" style="padding:40px 0px;">
                                <Row type="flex" justify="end">
                                    <Col span="12">
                                        <el-pagination
                                        @size-change="handleSizeChange"
                                        @current-change="handleCurrentChange"
                                        :current-page="currentPage"
                                        :page-sizes="[50, 100, 200, 500, 1000]"
                                        :page-size="pageSize"
                                        layout="total, sizes, prev, pager, next, jumper"
                                        :total="total">
                                        </el-pagination>
                                    </Col>
                                </Row>
                            </div>
                        </div>
                    </Row>
                </div>
                <!-- 表格 结束 -->
                <!-- 图表 开始 -->
                <div class="domain_echats"> 
                    <div class="domain_echats_graph">
                        <div class="domain_echats_header">
                            <p class="domain_echats_title">不同癌种数量</p>
                            <p v-if="!showNullEchart1" class="domain_echats_exchange">
                                <span @click="drawDiseaseStatisticsBar"><Icon type="stats-bars"></Icon></span>
                                <span @click="drawDiseaseStatisticsPie"><Icon type="pie-graph"></Icon></span>
                            </p>
                        </div>
                        <div id="difTumNum" style="height:300px;background:#FFF;line-height:400px;text-align:center;">
                            <img style="display:inline-block;" v-if="showNullEchart1" src="../img/null.png" />
                        </div>
                        <warn v-if="isEchartWarn" @callback="getProjects"></warn>
                    </div>
                    <div class="domain_echats_graph">
                        <div class="domain_echats_header">
                            <p class="domain_echats_title">本月收集病例数统计</p>
                            <p v-if="!showNullEchart2" class="domain_echats_exchange">
                                <span @click="drawCurStatisticsLine"><Icon type="ios-pulse"></Icon></span>
                                <span @click="drawCurStatisticsBar"><Icon type="stats-bars"></Icon></span>
                            </p>
                        </div>
                        <div id="curMouthNum" style="height:300px;background:#FFF;line-height:400px;text-align:center;">
                            <img style="display:inline-block;" v-if="showNullEchart2" src="../img/null.png" />
                        </div>
                        <warn v-if="isEchartWarn" @callback="getProjects"></warn>
                    </div>
                </div> 
                <!-- 图表 结束 -->
            </div>
            <!-- 功能区 结束 -->
            <!-- 弹层 开始 -->
            <Modal v-model="modal1" title="场景" class="newtumour" class-name="vertical-center-modal">
                <div class="scene">
                    <ul>
                        <li v-for="(item,index) of sceneList" @click="sceneChange(item,index)" :key="index">
                            <div>
                                <img :src="item.src" />
                                <span v-if="item.sceneShow==true" class="scene_icon"><Icon type="android-done"></Icon></span>
                            </div>
                            <p>{{item.title}}</p>
                        </li>
                    </ul>
                </div>
                <div class="slot-footer">
                    <Row>
                        <Col span="8"></Col>
                        <Col span="16" style="float:right;margin-top:10px;margin-right: -125px;">
                            <Button type="default" @click="modal1=false">取消</Button>
                            <Button type="primary" @click="handleSubmit">确定</Button> 
                        </Col>
                    </Row>
                </div>
            </Modal>
            <!--新建样本/编辑样本-->
            <Modal width="835px" v-model="sampleEdit" class="newtumour" :mask-closable="false" @on-cancel="resetForm">     
                <div class="sample-title">样本信息</div>
                <div class="sample-main">
                    <div class="stitle">
                        <Icon type="clipboard" style="font-size:22px;"></Icon>
                        <span style="padding-left:5px;">样本信息（*为必填项）</span>
                    </div>
                    <div class="sample-inner">
                        <Form :model="sampleInfo" label-position="left" ref="modelForm" :label-width="110" inline :rules="ruleCustom">
                            <Row>
                                <Col class="tables">
                                    <FormItem label="肿瘤分类" style="width:30%;" prop="region">
                                        <Select v-model="sampleInfo.region">
                                            <Option v-for="item in region" :value="item.name" :key="item.value">{{ item.name }}</Option>
                                        </Select>
                                    </FormItem>
                                    <FormItem label="样本编号" style="width:30%;" prop="samplecode">
                                        <Input v-if="sampleEditType==0" v-model.trim="sampleInfo.samplecode"></Input>
                                        <Input v-else-if="sampleEditType==1" disabled v-model="sampleInfo.samplecode"></Input>
                                    </FormItem>
                                </Col>
                                <Col class="tables">
                                    <FormItem label="样本来源" style="width:30%;" prop="samplesource">
                                        <Select v-model="sampleInfo.samplesource">
                                            <Option v-for="item in samplesource" :value="item.name" :key="item.value">{{ item.name }}</Option>
                                        </Select>
                                    </FormItem>
                                    <FormItem label="样本类型" style="width:30%;" prop="sampletype">
                                        <Select v-model="sampleInfo.sampletype">
                                            <Option v-for="item in sampletype" :value="item.name" :key="item.value">{{ item.name }}</Option>
                                        </Select>
                                    </FormItem>
                                </Col>
                                <Col class="tables">
                                    <FormItem label="分析类型" style="width:30%;" prop="analysisType">
                                        <Select v-model="sampleInfo.analysisType">
                                            <Option v-for="item in analysisType" :value="item.value" :key="item.value">{{ item.label }}</Option>
                                        </Select>
                                    </FormItem>
                                    <FormItem label="测序日期" style="width:30%;">
                                        <DatePicker type="date" v-model="seqdate"></DatePicker>
                                    </FormItem>
                                </Col>
                                <Col class="tables">
                                    <FormItem label="取样日期" style="width:30%;">
                                        <DatePicker type="date" v-model="takendate"></DatePicker>
                                    </FormItem>
                                    <FormItem label="测序平台" style="width:30%;">
                                        <Select v-model="sampleInfo.platform">
                                            <Option v-for="item in platform" :value="item.name" :key="item.value">{{ item.name }}</Option>
                                        </Select>
                                    </FormItem>
                                </Col>
                                <Col class="tables">
                                    <FormItem label="收样日期" style="width:30%;">
                                        <DatePicker type="date" v-model="receivedate"></DatePicker>
                                    </FormItem>
                                    <FormItem label="测序类型" style="width:30%;">
                                        <Select v-model="sampleInfo.seqtype">
                                            <Option v-for="item in seqtype" :value="item.name" :key="item.value">{{ item.name }}</Option>
                                        </Select>
                                    </FormItem>
                                </Col>
                            </Row>
                        </Form>
                    </div>
                </div>
                <div class="sample-footer">
                    <Row :gutter="16">
                        <Col span="8" pull="7">
                        <div class="add-save">
                            <Button type="primary" @click="keep('modelForm')">保存</Button>
                        </div>
                        </Col>
                        <Col span="8" pull="1">
                        <div class="add-upload">
                            <Button v-if="!uploadDisabled" type="primary" @click="uploadSample">上传</Button>
                        </div>
                        </Col>
                    </Row>
                </div>

            </Modal>

            <!--样本文件信息-->
            <Modal width="835px" v-model="sampleshow" class="newtumour" :mask-closable="false">
                <div class="sample-title">测序文件</div>
                <div class="sample-inner">
                    <div style="padding:20px 10px;">
                        <el-table border aligin="left" v-loading="fileLoading" element-loading-text="数据加载中，请稍后" :data="samplefile">
                            <el-table-column label="文件名称" prop="filename" min-width="150%"></el-table-column>
                            <el-table-column label="文件大小" prop="size" ></el-table-column>
                            <el-table-column label="上传时间" prop="uploaddate"></el-table-column>
                            <el-table-column label="状态"  prop="status" :formatter="statusFormatter"></el-table-column>
                        </el-table>
                    </div>
                </div>
            </Modal>

            <!--文件上传-->
            <Modal width="835px" v-model="upModal" class="newtumour" :mask-closable="false" @on-cancel="clearData">
                <div class="sample-title">文件上传</div>
                <div class="upload">
                    <Col span="24" class="demo-tabs-style2">
                        <Tabs type="card"  @on-click="serverlocal" v-model="tabsVal">
                            <TabPane label="upload" name="upload">
                                <div>
                                    <Upload ref="upload" multiple :action='urls' :headers="{'Authorization':this.$store.state.token}" show-upload-list :data="{'sampleid':this.samid,'userId':this.userId,'type':'vcf'}" 
                                    :on-success="upsuccess" :on-error="uperror" @clearFiles="clearFiles"> 
                                        <Button type="ghost" style="background:#4578ad;">上传文件</Button>
                                    </Upload>
                                </div>
                            </TabPane>
                            <TabPane label="harddisk" name="local">
                                <tree-grid :columns="columns"  ref="tree" :tree-structure="true" :data-source="fileCategoryList" :requestUrl="samid">
                                </tree-grid>
                            </TabPane>

                            <!-- 服务器上传tab -->
                            <TabPane label="server" name="server">
                                <div class="fun"></div>
                                <tree-grid :columns="columns"  ref="tree" :tree-structure="true" :data-source="fileServerCategoryList" :requestUrl="samid">
                                </tree-grid>
                            </TabPane>
                            <!-- 服务器上传tab结束 -->
                        </Tabs>
                    </Col>
                </div>
            </Modal>

            <!--删除确定-->
            <Modal v-model="removeModel" title="删除提示" class="newtumour" width="300" :mask-closable="false">
                <p style="padding:20px;text-align:center;">您确定要删除这条任务吗？</p>
                <div class="fastq-footer">
                    <Button size="small" type="primary" @click="saveInfoClick">确定</Button>
                </div>
            </Modal>
            <!-- 弹层 结束 -->
        </div>
    </div>
</template>
<script>
// echarts相关
let echarts = require('echarts/lib/echarts');
// 引入饼图组件
require('echarts/lib/chart/bar');
require('echarts/lib/chart/pie');
// 引入提示框和图例组件
require('echarts/lib/component/tooltip')
require('echarts/lib/component/legend')

import {filePath, httpUrl,apiUrl } from 'common/js/Base';
import {tumour} from 'api/index.js'
import {getCookie} from '@/common/js/cookie.js'
import warn from "@/components/warn.vue";
import treeGrid from '@/components/transfer/treeTable/TreeGrid'
export default{
    name:'test',
    data(){
        const VariantTypeSamplecode = (rule, value, callback) => {
            console.log(rule, value, callback)
            if (value === ''|| value == undefined) {
                callback(new Error('分析类型不能为空'));
            }else{
                callback()
            }
        };
        return{
            modal1:false,           //新建病例弹层
            isWarn: false,
            urls:"",
            isEchartWarn:false,
            emptyShow: false,
            radio5: '诊断治疗',      //表格切换
            searchData:'',          //搜索框的值
            httpUrl: tumour.downLoadHttpUrl, //服务地址
            searchValue:'',         //关键词  
            scenceUrl:'',           //场景地址
            searchList:[{           //搜索下拉菜单
                label:"全部数据",
                value:"all"
            },{
                label:"病人编号",
                value:"patientcode"
            },{
                label:"样本编号",
                value:"samplecode"
            }],
            sceneList:[{            //弹层内容
                title:"早期筛查",
                src:require('../img/scence1.png'),
                sceneShow:false,
                projecttype:1,
            },{
                title:"个体治疗",
                src:require('../img/scence2.png'),
                sceneShow:false,
                projecttype:2,
            }],
            tableData3:[],         //表格数据    
            difTumNumList:[],      //不同癌种的样本数量
            curMouthList:[],     //当前月不同癌种的样本数量
            sampleEditType:0,    //样本编号状态 0为添加 1为编辑
            loading:false,         //加载loading
            fileLoading:false,
            currentPage:1,
            pageSize:50,          //每页50条
            total:0,
            sampleEdit: false,  //点击编辑 弹窗
            sampleInfo: {},  //样本信息弹窗信息
            ruleCustom: {  //表单验证
                samplecode: [
                    {required: true, message: '样本编号不能为空', trigger: 'blur' }
                ],
                sampletype: [
                    { required: true, message: '样本来源不能为空', trigger: 'blur' }
                ],
                samplesource: [
                    { required: true, message: '样本类型不能为空', trigger: 'blur' }
                ],
                region:[
                    {required: true, message: '测序区域不能为空', trigger: 'blur' }
                ],
                analysisType: [
                    { required: true,validator: VariantTypeSamplecode, trigger: 'blur' }
                ],
            },
            takendate:'',  //日期
            receivedate:'',
            seqdate:'',
            cancelStyle: {
                "lungCancel": "1",      //肺癌
                "gastricCancer": "2",   //胃癌
                "colorectalCancer": "3", //结直肠癌
                "breastCancel": "4"    //乳腺癌
            },
            samplesource: [],//样本来源下拉
            sampletype: [],  //样本来源下拉
            region: [],      //测序区域下拉
            platform: [],    //测序平台下拉菜单
            seqtype: [],     //测序类型下拉菜单
            sampleshow:false,   //点击样本编号 弹窗
            samplefile:[],  //样本文件信息弹窗信息
            upModal: false,   //点击上传 弹窗
            tabsVal:'upload',  //绑定文件上传页面的当前tab
            patid:'',  //存储patientid
            samid:'',  //存储sampleid
            userId:'',
            analysisType:[
                {
                    value: 0,
                    label: 'Germline'
                },
                {
                    value: 1,
                    label: 'Somtic'
                }
            ],
            columns: [  //树形图label
                {
                    text: '文件名称',
                    dataIndex: 'filename',
                    width:'40%'
                },
                {
                    text: '文件大小',
                    dataIndex: 'size',
                    width:'10'
                },
                // {
                //     text: '传输时间',
                //     dataIndex: 'transition',
                //     width:'10'
                // }
            ],
            removeModel:false,//删除确定
            fileCategoryList: [],                // 本地
            fileServerCategoryList: [],          // 服务
            pageIndex:1,
            dataSize:{
                notUploadCount:0,
                pipelineFinishCount:0,
                downloadCount:0
            },
            uploadDisabled:false,
            showNullEchart1:false,
            showNullEchart2:false
        }
    },
    watch: {
        "sampleInfo.samplecode": function(val, oldval) {
            this.sampleInfo.samplecode = val.replace(/\s|\xA0/g, "");
        }
    },
    methods:{
        //取消必填选项
        resetForm() {
            this.$refs.modelForm.resetFields();
        },
        samcode(index,row){ //点击样本编号
            this.sampleshow=true;
            this.samplefile=[];
            let obj={
                "userId":getCookie("userid"),
                "sampleid":row.dchSampleList[index].sampleid,
                "productId":"3"
            }
            this.fileLoading = true;
            tumour.getFileList(obj).then((data)=>{
                if(data.returnCode || data.returnCode==200){
                    if(data.data==null||data.data=="null"){
                        this.$Message.error(data.msg);
                    }else{
                        this.samplefile=data.data;
                    }
                }else if(data.returnCode==422 || data.returnCode==204){
                    this.$router.push('/login')
                }else{
                    this.$Message.error(data.msg)
                }
                this.fileLoading = false;
            }).catch((error)=>{
                this.fileLoading = false;
            })            
        },
        // 获得本地/opt/NfsDir/PublicDir/demo/
        _getLocalDataList() {
            let obj={
                "path": filePath.path.local,
                "userId":getCookie("userid"),
                "productId":"3",
                "type":"2"
            }
            tumour.getSingleForldList(obj).then((data)=>{
                if(data.returnCode==0 || data.returnCode==200){
                    if(M.isArray(data.data)) {
                        this.fileCategoryList=data.data;
                    }
                }else if(data.returnCode==422 || data.returnCode==204){
                    this.$router.push('/login')
                }else{
                    this.$Message.error(data.msg)
                }
                
            }).catch((error)=>{

            })
        },
        // 获得服务列表 /opt/NfsDir/PublicDir/demo/
        // /opt/NfsDir/PublicDir/demo/
        _getServerDataList() {
            let obj={
                "path": filePath.path.server,
                "userId":getCookie("userid"),
                "productId":"3",
                "type":"2"
            }
            tumour.getSingleForldList(obj).then((data)=>{
                if(data.returnCode==0 || data.returnCode==200){
                    if(M.isArray(data.data)) {
                        this.fileServerCategoryList=data.data;
                    }
                }else if(data.returnCode==422 || data.returnCode==204){
                    this.$router.push('/login')
                }else{
                    this.$Message.error(data.msg)
                }
            }).catch((error)=>{

            })
        },
        dataChange(searchValue,keyWord){
            let obj={
                "pageSize" : this.pageSize,
                "pageIndex" : this.pageIndex,
                "productId" : "3",
                "userId":getCookie("userid"),
            }
            this.tableData3=[];
            this.total=0;
            this.currentPage=1;
            if(searchValue!='' && searchValue!="all"){
                obj.searchColumn=searchValue;
                obj.keyword=keyWord;
            }
            this.loading = true;
            tumour.getProjectList(obj).then((data)=>{
                if(data.returnCode==0 || data.returnCode==200){
                    if(data.data!=null){
                        this.total=data.data.count;
                        this.tableData3=data.data.projectList;
                    }else{
                        this.$Message.error(data.msg);
                        this.emptyShow = true;
                    }
                    this.loading = false;
                }else if(data.returnCode==422 || data.returnCode==204){
                    this.$router.push('/login')
                }else{
                    this.$Message.error(data.msg);
                    this.loading = false;
                }
                this.isWarn = false;
                if (this.tableData3 == null || this.tableData3.length == 0) {
                    this.emptyShow = true;
                } else {
                    this.emptyShow = false;
                }
            }).catch((error)=>{
                this.isWarn = true;
                this.loading = false;
                //this.$Message.error(error.statusText);
            })
        },
        saveInfoClick(){  //删除确定
            let obj={
                "idList":this.idList,
                "userId":getCookie('userid'),
                "productId":"3"
            }
            tumour.deleteSampleById(obj).then((data)=>{
                if(data.returnCode==0 || data.returnCode==200){
                    this.$Message.success(data.msg);
                    this.removeModel=false;
                    this.load();
                }else if(data.returnCode==422 || data.returnCode==204){
                    this.$router.push('/login')
                }else{
                    this.$Message.error(data.msg);
                    this.removeModel=false;
                    this.load();
                }
            })
        },
        clearFiles(){
            const fileList = this.$refs.upload.fileList;
            this.$refs.upload.fileList.splice(fileList.indexOf(file), 1);
        },
        upsuccess(response, file, fileList){  //本地上传成功
            if(response.returnCode==0){
                this.$Message.success(response.msg)
            }else if(response.returnCode==217){
                this.$Message.error(response.msg)
            }
            this.$refs.upload.clearFiles();
        },
        uperror(error, file, fileList){  //本地上传失败
            console.log(error);
            this.$Message.error(error.msg)
        },
        // tabs切换事件
        serverlocal(name){  //serverlocal
            if(name=='local') {
                this._getLocalDataList();
                this.$store.state.treeGrid=1;
            }else if(name=='server') {
                this._getServerDataList();
                this.$store.state.treeGrid=2;
            }
        },
        //关闭上传文件弹层清空数据
        clearData(){
            this.tabsVal='upload'
            this.fileCategoryList=[];
            this.fileServerCategoryList=[];
        },
        //格式化文件状态
        statusFormatter(row, column,cellValue){
            switch(row.status){
                case "1":
                    return '正在上传';
                    break;
                case "2":
                    return '上传完成';
                    break;
                case "3":
                    return '上传失败';
                    break;
            }
        },
        // 上传
        uploadSample(){
            this.sampleEdit = false;
            this.upModal = true;
        },
        //每页显示改变
        handleSizeChange(val) {
            this.pageSize=val;
            this.load();
        },
        //页码改变
        handleCurrentChange(val) {
            this.pageIndex=val;
            this.load();
        },
        //跳转Vishuourl
        jumpVishuourl(sampleid,patientid){
            let obj={
                "userId":getCookie("userid"),
                "sampleid":sampleid,
                // "patientid":patientid,
                "productid":"3"
            }
            tumour.vishuourl(obj).then((data)=>{
                if(data.returnCode==0 || data.returnCode==200){
                    if(data.data=="null" || data.data==null){
                        this.$Message.error(data.msg)
                        // this.show=false;
                    }else{
                        this.$store.state.vishuourlUrl=data.data;
                        this.$router.push('/tumour/cgdap')
                    }
                }else if(data.returnCode==422 || data.returnCode==204){
                    this.$router.push('/login')
                }else{
                    this.$Message.error(data.msg)
                }
            }).catch((error)=>{
            })
        },
        edit(index,row){ //点击编辑
            this.sampleEditType = 1;
            this.sampleInfo={};
            this.sampleEdit = true;
            this.upModal = false;
            this.patid=row.dchPatient.patientid;
            this.samid=row.dchSampleList[index].sampleid;
            this.sampleInfo=M.extend(this.sampleInfo,row.dchSampleList[index]);
            this.seqdate=row.dchSampleList[index].seqdate;
            this.takendate=row.dchSampleList[index].takendate;
            this.receivedate=row.dchSampleList[index].receivedate;
        },
        keep(name) {  //点击保存
            let obj = {
                userId: getCookie("userid"),
                patientid: this.patid,
                productId: "3",
                version:"2.0",
                takendate: String(this.takendate),
                receivedate: String(this.receivedate),
                seqdate: String(this.seqdate)
            }
            M.extend(this.sampleInfo, obj)
            this.$refs[name].validate((valid) => {
                if (valid) {
                    if (M.has(this.sampleInfo, 'sampleid') == true) {
                        tumour.updateSample(this.sampleInfo).then((data) => {
                            if (data.returnCode == 0 || data.returnCode == 200) {
                                this.$Message.success(data.msg);
                                this.uploadDisabled = false;
                                this.load();
                            } else if (data.returnCode == 422 || data.returnCode == 204) {
                                this.$router.push('/login')
                            } else {
                                this.$Message.error(data.msg)
                            }

                        })
                    } else {
                        tumour.addSample(this.sampleInfo).then((data) => {
                            if (data.returnCode == 0 || data.returnCode == 200) {
                                if (data.data == "null" || data.data == null) {
                                    this.$Message.error(data.msg);
                                } else {
                                    this.$Message.success(data.msg);
                                    this.uploadDisabled = false;
                                    this.load();
                                    this.samid = data.data.sampleid;
                                }
                            } else if (data.returnCode == 422 || data.returnCode == 204) {
                                this.$router.push('/login')
                            } else {
                                this.$Message.error(data.msg)
                            }
                        })
                    }
                }
            })
        },
        delet(index,row){  //删除样本
            this.removeModel=true;
            this.idList=[];
            if(row.dchSampleList.length==1){
                index=0;
            }
            this.idList.push(row.dchSampleList[index].sampleid)
        },
        run(index,row){  //点击运行
            this.samid=row.dchSampleList[index].sampleid;
            this.pipeline=row.dchSampleList[index].region;
            this.pipeline=this.getPiplineType(this.pipeline);
            let obj={//只能是wes 其他的禁用   不会 iview的下拉框可以这么干？
                "paientId":row.dchPatient.patientid,
                "productid":"3",
                "userId":getCookie("userid"),
                // "sampleId":this.samid,
                // "userId":getCookie("userid"),
                // "productId":"3",
                // "pipeline": 2,             
                // "templateId": "0",
                // "fileGroupId":"aa",
            }
            tumour.executeSample(obj).then((data)=>{
                if(data.returnCode==200 || data.returnCode==0){
                    // 再次获取列表
                    this.load();
                    this.$Message.success("添加成功")
                }else if(data.returnCode==422 || data.returnCode==204){
                    this.$router.push('/login')
                }else{
                    this.$Message.error(data.msg)
                }
            }) 
        },
        //获取pipline字段类型
        getPiplineType(name){
            let ret="0";
            switch(name){
                case "请选择":
                    ret="0";
                    break;
                case "肺癌早筛基因检测panel":
                    ret="101";
                    break;
                case "EGFR突变ARMS检测":
                    ret="102";
                    break;
                case "EGFR T790M突变检测":
                    ret="103";
                    break;
                case "ALK融合Ventana免疫组化检测":
                    ret="104";
                    break;
                case "ALK FISH":
                    ret="105";
                    break;
                case "ALK RT-PCR检测":
                    ret="106";
                    break;
                case "ROS1 RT-PCR检测":
                    ret="107";
                    break;
                case "BRAF V600E突变检测":
                    ret="108";
                    break;
                case "RET基因融合检测":
                    ret="109";
                    break;
                case "HER2点突变检测":
                    ret="110";
                    break;
                case "MET表达量或转录本剪切检测":
                    ret="111";
                    break;
                case "KRAS点突变检测":
                    ret="112";
                    break;
                case "PIK3CA突变":
                    ret="113";
                    break;
                case "NCCN指南8基因检测panel":
                    ret="114";
                    break;
                case "耐药性基因检测panel":
                    ret="115";
                    break;
                case "癌症基因检测panel":
                    ret="116";
                    break;
                case "肿瘤负荷监测":
                    ret="117";
                    break;
            }
            return Number(ret);
        },
        addsample(row){//点击添加
            this.sampleEditType = 0,
            this.patid=row.dchPatient.patientid;
            this.sampleEdit=true;
            this.samid='';
            this.sampleInfo={};
            this.uploadDisabled = true;
            this.takendate = "";
            this.receivedate = "";
            this.seqdate = "";
        },
        //点击病人编号
        clickPatientcode(row){
            this.$store.state.tumourPatientInfo.tumourPatientId=row.dchPatient.patientid;
            this.$store.state.tumourPatientInfo.tumourpatientCode=row.dchPatient.patientcode;
            this.$router.push('/tumour/diseaseInfo');
        },
        selectChange(val){          //关键词选择
            this.pageIndex=1;
            this.currentPage=1;
            this.keyword='';
            switch(val){
                case 'patientcode':
                  this.searchValue="1";
                  break;
                case 'samplebatch':
                  this.searchValue="2";
                  break;  
                case 'samplecode':
                  this.searchValue="3";
                  break;  
            } 
        },
        sceneChange(item,index){    //弹层选择内容切换
            console.log(index);
            this.scenceUrl=String(index);
            this.$store.state.projecttype=item.projecttype;
            if(item.sceneShow){
                item.sceneShow=false;
            }else{
                item.sceneShow=true;
                if(index==0){
                    this.sceneList[1].sceneShow=false;
                }else{
                    this.sceneList[0].sceneShow=false;
                }
            }
        },
        newCase(){              //新建病例
            this.modal1=true;
            M.each(this.sceneList,(item)=>{
                item.sceneShow=false;
            })
        },
        handleSubmit(){
            console.log(this.scenceUrl);
            if(this.scenceUrl==""){
                this.$Message.error("请选择场景");
            }else{
                if(this.scenceUrl==0){
                    this.$Message.error("该功能暂未开放");
                }else if(this.scenceUrl==1){
                    this.$store.state.tumourPatientInfo.tumourPatientId="";
                    this.$store.state.tumourPatientInfo.tumourpatientCode="";
                    this.$store.state.tumourPatientInfo.tumourProjectId = "";
                    this.$router.push('/tumour/diseaseInfo');
                }
            }
            
        },
        load(){
            let obj={
                "pageSize" : this.pageSize,
                "pageIndex" : this.pageIndex,
                "productId" : "3",
                "userId":getCookie("userid")
            }
            this.tableData3=[];
            this.loading = true;
            tumour.getProjectList(obj).then((data)=>{
                if(data.returnCode==0 || data.returnCode==200){
                    if(data.data!=null){
                        this.total=data.data.count;
                        this.tableData3=data.data.projectList;
                    }else{
                        this.$Message.error(data.msg);
                        this.emptyShow = true;
                    }
                    this.loading = false;
                }else if(data.returnCode==422 || data.returnCode==204){
                    this.$router.push('/login')
                }else{
                    this.$Message.error(data.msg);
                    this.loading = false;
                }
                this.isWarn = false;
                if (this.tableData3 == null || this.tableData3.length == 0) {
                    this.emptyShow = true;
                } else {
                    this.emptyShow = false;
                }
            }).catch((error)=>{
                this.isWarn = true;
                this.loading = false;
            })
            
        },
        getCounts(){
            let obj={
                "productId" : "3",
                "userId":getCookie("userid")
            }
            tumour.getCounts(obj).then((data)=>{
                if(data.returnCode==0 || data.returnCode==200){
                    this.dataSize=data.data;
                }else if(data.returnCode==422 || data.returnCode==204){
                    this.$router.push('/login')
                }
            })
        },
        //获取当前月份不同癌种的样本数量数据
        getCurMouthNum(){
            let obj= {
                    "productId": "3",
                    "type":"mm",
                    "userId": getCookie("userid")
            };
            tumour.statisticalchart(obj).then((data) => {
                if (data.returnCode == 0 || data.returnCode == 200) {
                    this.buildCurMouthList(data.data);
                    this.drawCurStatisticsBar();
                } else if (data.returnCode == 422 || data.returnCode == 204) {
                    this.$router.push('/login')
                } else {
                    this.$Message.error(data.msg)
                }
            }).catch((error) => {
                this.$Message.error(error.statusText);
            });          
        },
        //获取不同癌种的样本数量数据
        getDiftumNum(){
            let obj={
                "productId" : "3",
                "userId":getCookie("userid")
            };
            tumour.getDiseaseStatistics(obj).then((data)=>{
                if(data.returnCode==0 || data.returnCode==200){
                    this.difTumNumList=data.data;
                    this.drawDiseaseStatisticsPie();
                }else if(data.returnCode==422 || data.returnCode==204){
                    this.$router.push('/login')
                }else {
                    this.$Message.error(data.msg)
                }
            }).catch((error)=>{
                this.$Message.error(error.statusText);
            });
        },
        //当前月不同癌种的样本数量 柱状图
        drawCurStatisticsBar(){
            let echart = echarts.init(document.getElementById('curMouthNum'));
            let diseaseName = this.getDiseaseName(this.curMouthList);
            let diseaseCount = this.getDiseaseCount(this.curMouthList);
            let option = {
                xAxis: {
                    type: 'category',
                    data: diseaseName,
                     axisLabel: {
                        interval: 0,
                        rotate: -30
                    }
                },
                yAxis: {
                    splitLine: { show: false }  //改设置不显示坐标区域内的y轴分割线
                },
                legend: {
                    bottom: "10",
                    data: diseaseName,
                },
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                        type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                    },
                },
                series: [{
                    name: "数量",
                    type: 'bar',
                    data: diseaseCount,
                    //设置柱子的宽度
                    barWidth: 30,
                    //配置样式
                    itemStyle: {
                        //通常情况下：
                        normal: {
                            //每个柱子的颜色即为colorList数组里的每一项，如果柱子数目多于colorList的长度，则柱子颜色循环使用该数组
                            color: function(params) {
                                var colorList = ['rgb(21,154,141)', 'rgb(215,57,73)', 'rgb(0,204,0)', 'rgb(53,160,214)', 'rgb(217,123,36)'];
                                return colorList[params.dataIndex];
                            }
                        },
                        //鼠标悬停时：
                        emphasis: {
                            shadowBlur: 10,
                            shadowOffsetX: 0,
                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                        }
                    },
                }],
                //控制边距　
                grid: {
                    left: '10%',
                    right: '10%',
                    containLabel: true,
                },
            };
            echart.clear();
            echart.setOption(option);
        },
        //当前月不同癌种的样本数量 折线图
        drawCurStatisticsLine(){
            let echart = echarts.init(document.getElementById('curMouthNum'));
            let diseaseName = this.getDiseaseName(this.curMouthList);
            let diseaseCount = this.getDiseaseCount(this.curMouthList);
            let option = {
                xAxis: {
                    type: 'category',
                    data: diseaseName,
                    axisLabel:{
                        interval:0,
                        rotate:-30
                    }
                },
                yAxis: {
                    type: 'value'
                },
                series: [{
                    data: diseaseCount,
                    type: 'line'
                }],
                 //控制边距　
                grid: {
                    left: '10%',
                    right: '10%',
                    containLabel: true
                },
            };
            echart.clear();
            echart.setOption(option);
        },
        //不同癌肿的样本数量 柱状图
        drawDiseaseStatisticsBar(){
            let echart = echarts.init(document.getElementById('difTumNum'));
            let diseaseName=this.getDiseaseName(this.difTumNumList);
            let diseaseCount= this.getDiseaseCount(this.difTumNumList);
            let option = {
                xAxis: {
                    data: diseaseName,
                     axisLabel: {
                        interval: 0,
                        rotate: -30
                    }
                },
                yAxis: {
                    splitLine: { show: false }  //改设置不显示坐标区域内的y轴分割线
                },
                legend: {
                    bottom:"10",
                    data:diseaseName,
                },
                tooltip:{
                    trigger: 'axis',
                    axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                        type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                    },
                },
                series: [{
                    name: "数量",
                    type: 'bar',
                    data: diseaseCount,
                    //设置柱子的宽度
                    barWidth: 30,
                    //配置样式
                    itemStyle: {
                        //通常情况下：
                        normal: {
                            //每个柱子的颜色即为colorList数组里的每一项，如果柱子数目多于colorList的长度，则柱子颜色循环使用该数组
                            color: function(params) {
                                var colorList = ['rgb(21,154,141)', 'rgb(215,57,73)', 'rgb(0,204,0)', 'rgb(53,160,214)' , 'rgb(217,123,36)'];
                                return colorList[params.dataIndex];
                            }
                        },
                        //鼠标悬停时：
                        emphasis: {
                            shadowBlur: 10,
                            shadowOffsetX: 0,
                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                        }
                    },
                }],
                //控制边距　
                grid: {
                    left: '10%',
                    right: '10%',
                    containLabel: true
                },
            };
            echart.clear();
            echart.setOption(option);
        },
        //不同癌肿的样本数量 饼状图
        drawDiseaseStatisticsPie(){
            let echart = echarts.init(document.getElementById('difTumNum'));
            let diseaseName=this.getDiseaseName(this.difTumNumList);
            let data= this.getData(this.difTumNumList);
            let option = {
                tooltip: {
                    trigger: 'item',
                    formatter: "{a} <br/>{b}: {c} ({d}%)"
                },
                legend: {
                    bottom: 10,
                    left: 'center',
                    data: diseaseName
                },
                series: [
                    {
                        name: '癌种',
                        type: 'pie',
                        center: ['50%', '42%'],
                        avoidLabelOverlap: false,
                        label: {
                            normal: {
                                show: false,
                            },
                        },
                        labelLine: {
                            normal: {
                                show: false
                            }
                        },
                        data: data
                    }
                ]
            };
            echart.clear();
            echart.setOption(option);
        },
        //创建当前月 癌种数量数据结构
        buildCurMouthList(data){
            let _this=this;
            for(var i=0;i<data.length;i++){
                let now={}
                if(data[i].cancertype==_this.cancelStyle.lungCancel){
                    data[i].cancertype="肺癌";
                }else if(data[i].cancertype==_this.cancelStyle.gastricCancer){
                    data[i].cancertype="胃癌";
                }else if(data[i].cancertype==_this.cancelStyle.colorectalCancer){
                    data[i].cancertype="结直肠癌";
                } else if (data[i].cancertype == _this.cancelStyle.breastCancel) {
                    data[i].cancertype = "乳腺癌";
                };
                //  obj={
                //     "count":data[i].count,
                //     "name":data[i].cancertype
                // }
                now.count=data[i].count;
                now.name=data[i].cancertype;
                this.curMouthList.push(now || {});
            }
        },
        //获取不同癌种的名称
        getDiseaseName(list){
            let ret=[];
            M.each(list, function(item) {
                let name = item.name;
                ret.push(name || "");
            });
            return ret;
        },
        //获取不同癌种的数量
        getDiseaseCount(list){
            let ret=[];
            M.each(list, function(item) {
                let count = item.count;
                ret.push(count || "");
            });
            return ret;
        },
        //获取不同癌种的样本数量 饼状图数据结构
        getData(list){
            let ret=[];
            M.each(list, function(item) {
                let obj={
                    "value": item.count,
                    "name" : item.name
                };
                ret.push(obj || {});
            });
            return ret;
        },
        //获取样本下拉菜单
        getSampleOption() {
            let obj = {
                "userId": getCookie("userid"),
                "productId": "3"
            };
            tumour.getSampleOption(obj).then((data) => {
                if (data.returnCode == "200" || data.returnCode == "0") {
                    if (data.data) {
                        this.buildSampleData(data.data);
                    }
                } else if (data.returnCode == 422 || data.returnCode == 204) {
                    this.$router.push('/login')
                } else {
                    this.$Message.error(data.msg)
                }
            }).catch((error) => {
                this.$Message.error(error.statusText);
            })
        },
        //文件下载
        download(row){
            let obj={
                patientid:row.dchPatient.patientid
            }
            row.downloading = true;
            var that =this;
            tumour.downloadReport(obj).then((res)=>{
                if(res.returnCode==0||res.returnCode==200){
                    // let iframe = document.createElement('iframe')
                    // iframe.style.display = 'none'
                    // iframe.src = res.data;
                    // document.body.appendChild(iframe);
                    // //防止下载两次
                    // setTimeout(function() {
                    //     document.body.removeChild(iframe)
                    // }, 1000);
                    let a = document.createElement('a');
                    a.setAttribute("target","_blank");
                    a.setAttribute("href",res.data);
                    a.setAttribute("download","download");
                    document.body.appendChild(a);
                    a.click();
                    document.body.removeChild(a);
                }
                else{
                    this.$Message.error(res.msg);
                }
                row.downloading = false;
            }).catch((error)=>{
                row.downloading = false;
                this.$Message.error(error);
            })
        },
        //创建下拉菜单数据结构
        buildSampleData(data) {
            this.samplesource = data.sampleSourceLists;
            this.sampletype = data.sampleTypeLists;
            this.platform = data.seqPlatformLists;
            this.seqtype = data.seqTypeLists;
            this.region = data.tumorTypeLists;
        },
        //获取页面数据
        getProjects(){
            let obj = {
                "userId": getCookie("userid"),  
                "productId": "3",
                "type": "mm"
            };
            tumour.getProjects(obj).then((data) => {
                if (data.returnCode == 200 || data.returnCode == 0) {
                    if(data.data){
                        this.initPage(data.data);
                    }
                } else if (data.returnCode == 422 || data.returnCode == 204) {
                    this.$router.push('/login')
                } else {
                    this.$Message.error(data.msg)
                }
                this.isEchartWarn = false;
            }).catch((error) => {
                this.isEchartWarn = true;
            })
        },
        //初始化页面数据
        initPage(data) {
            //头部 待上传 已完成 报告下载数据
            if(data.projectCountModel){
                this.dataSize = data.projectCountModel;
            }
            // 不同癌种 的数量
            this.difTumNumList = data.profileModelList;
            if(this.difTumNumList.length<=0){
                this.showNullEchart1=true;
            }else{
                //不同癌种饼状图
                this.drawDiseaseStatisticsPie();
            }
           if(data.statisticsModelList.length<=0){
                this.showNullEchart2=true;
           }else{
                //当月癌种数量
                this.buildCurMouthList(data.statisticsModelList);
                //当月癌种数量 柱状图
                this.drawCurStatisticsBar();
           }
           
        },
    },
    mounted(){
        this.load();
        // this.getCounts();
        //获取不同癌肿样本量
        // this.getDiftumNum();
        // this.getCurMouthNum();
        //获取样本下拉菜单
        this.getSampleOption();
        //获取页面数据
        this.getProjects();
        this.userId = getCookie("userid");
        this.urls=apiUrl.rare + 'template/upload/fileUpload';
    },
    components: {
        treeGrid,
        warn
    },
    // filters: {
    //         // 格式化数据
    //         dataFormat(cellValue) {
    //             if(cellValue=='0' || cellValue=='5'){
    //                 return cellValue = "----"
    //             }else if(cellValue=='1' ) {
    //                 return cellValue = "等待"
    //             }else if(cellValue=='2') {
    //                 return cellValue = "正在运行"
    //             }else if(cellValue=='3') {
    //                 return cellValue = "已完成"
    //             }else if(cellValue=='4') {
    //                 return cellValue = "错误"
    //             }else if(cellValue=='6') {
    //                 return cellValue = "未执行"
    //             }
    //         },
    //     },
}   
</script>

